/*
 * (C) Copyright 2016 Ymatou (http://www.ymatou.com/).
 * 
 * All rights reserved.
 */
package com.ymatou.iapi.userservice.parameter.enums;

/**
 * 终端类型
 * @author zhongwei
 *
 */
public enum TerminalSourceEnum {

    /**
     * 其他
     */
    Other(0, "Other"),

    /**
     * PC
     */
    PC(1, "Pc"),

    /**
     * IOS
     */
    IOS(2, "Ios"),

    /**
     * Android
     */
    Android(3, "Android"),

    /**
     * PAD
     */
    PAD(4, "IPad"),
    ;

    private Integer code;

    private String message;

    TerminalSourceEnum(Integer code, String message) {
        this.code = code;
        this.message = message;
    }

    public Integer getCode() {
        return code;
    }

    public String getMessage() {
        return message;
    }

    /**
     * 通过错误码获取枚举项
     *
     * @param code
     * @return
     */
    public static TerminalSourceEnum getByCode(Integer code) {
        for (TerminalSourceEnum terminalSourceEnum : TerminalSourceEnum.values()) {
            if (terminalSourceEnum.getCode() == code) {
                return terminalSourceEnum;
            }
        }
        return null;
    }
}
